package ru.ifmo.metopt.task;

import ru.ifmo.metopt.abstracts.Function;
import ru.ifmo.metopt.abstracts.Task;

/**
 * @author avhaliullin
 */
public class MyTask implements Task {
    @Override
    public Function getFunction() {
        return new Function2D() {
            @Override
            protected double safeF(double... args) {
                return args[0] * args[0] + args[1] * args[1] - 4 * args[0] + 4;
            }
        };
    }

    @Override
    public Function[] getRestrictions() {
        Function[] res = new Function[4];
        int index = 0;
        res[index++] = new Function2D() {
            @Override
            protected double safeF(double... args) {
                return args[1] - Math.pow(args[0], 6) - 1;
            }
        };
        res[index++] = new Function2D() {
            @Override
            protected double safeF(double... args) {
                return args[0] - args[1] + 1.8;
            }
        };
        res[index++] = new Function2D() {
            @Override
            protected double safeF(double... args) {
                return args[0];
            }
        };
        res[index++] = new Function2D() {
            @Override
            protected double safeF(double... args) {
                return args[1];
            }
        };
        return res;
    }

    @Override
    public double[] getInitialPoint() {
        return new double[]{0.7, 1.3};
    }
}
